package IU;

import Controladores.CtrlClasificacion;
import Entidades.Producto;
import Entidades.Proveedorproducto;
import java.util.List;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import utiles.Validador;
import Controladores.CtrlLocalidad;
import Controladores.CtrlPais;
import Controladores.CtrlProducto;
import Controladores.CtrlProveedor;
import Controladores.CtrlProvincia;
import Controladores.CtrlProveedorProducto;
import Controladores.CtrlMarca;
import Controladores.CtrlModelo;
import Controladores.CtrlTransporte;
import Controladores.CtrlEstadotransporte;
import Controladores.CtrlEstadoespera;

import Entidades.Clasificacionproducto;
import Entidades.Estadoespera;
import Entidades.Marca;
import Entidades.Modelo;
import Entidades.Proveedor;
import Entidades.Transporte;
import IU.CargarRemito;
import java.util.ArrayList;

/**
 *
 * @author  Laura
 * 
 * ESTARÍA BUENO QUE HABILITE EL BOTÓN AGREGAR CUANDO ESTÉ SELECCIONADO EL PRODUCTO Y LUEGO EL PROVEEDOR.
 * NO FUNCIONA EL BOTÓN ELIMINAR
 * 
 * 
 */
public class ABMTransporte extends javax.swing.JFrame {

    private String patente, tara, taraacoplado;
    Producto producto;
    TablaPersonalizada tableModel;
    private List lista, listaprov, listacla, listapp, listap;
    CtrlProveedor controladorprovee;
    CtrlProducto controladorprod;
    CtrlClasificacion controladorclas;
    CtrlPais controladorpais;
    CtrlProvincia controladorprov;
    CtrlLocalidad controladorlocal;
    CtrlProveedorProducto controladorprovprod;
    CtrlMarca controladormarca;
    CtrlModelo controladormodelo;
    CtrlTransporte controladortransporte;
    Proveedor o;
    Validador validador;
    Proveedorproducto pp;
    Proveedor misproveedores = null;
    //private List listaep, listatd, listaprov, listapais, listaloc, listao, listac;
    //acá ver si puedo hacer lo mismo con pais provincia traer la collection de provincia
    //  Collection<Localidad> localidadesCollection = new ArrayList<Localidad>();
    // Estadopersona miestado = null;
    Clasificacionproducto clasificacion = null;
    Vector estosproveedores = new Vector();
    Producto productoSel;
    Proveedor proveedorSel;
    Proveedorproducto provprod;
    List<Marca> listamarca = new ArrayList<Marca>();
    List<Modelo> listamodelo = new ArrayList<Modelo>();
    Marca marca;
    Modelo modelo;
    Estadoespera estadoespera;
    CtrlEstadoespera controladorestadoespera;
    CtrlEstadotransporte controladorestadotransporte;
    int acoplado;
    private final String op;

    public ABMTransporte(String operario) {
        initComponents();

        controladorpais = new CtrlPais();
        controladorprov = new CtrlProvincia();
        controladorlocal = new CtrlLocalidad();
        controladorprovee = new CtrlProveedor();
        controladorprod = new CtrlProducto();
        controladorclas = new CtrlClasificacion();
        controladorprovprod = new CtrlProveedorProducto();
        controladormarca = new CtrlMarca();
        controladormodelo = new CtrlModelo();
        controladortransporte = new CtrlTransporte();
        controladorestadotransporte = new CtrlEstadotransporte();
        controladorestadoespera = new CtrlEstadoespera();
        op = operario;
        jTextFieldUsuario2.setText(op);

        //alta

        // cargarComboProveedores();
        cargarComboMarca();
        cargarComboModelo();
        cargarComboMarca1();
        cargarComboModelo1();
        cargarComboPatente();
        //fin alta
        //consultar
//        cargarComboNombreProducto();
        //fin consultar
        //modificar
        cargarTabla();
        //  cargarComboProveedores1();
//        cargarComboClasificacion1();
//AGREGAR PROVEEDOR A PRODUCTO:
//        cargarComboNombreProdAgregar();
//        limpiarCamposProdAgregar();
//        cargarComboRazonAgregar();
        // cargarComboPaises1();
//        cargarComboProvincias1();
//        cargarComboLocalidades1();
//        
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jButtonGuardar = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        jTextFieldTara = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jTextFieldPatente = new javax.swing.JTextField();
        jComboBoxMarca = new javax.swing.JComboBox();
        jLabel10 = new javax.swing.JLabel();
        jComboBoxModelo = new javax.swing.JComboBox();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTableProductos = new javax.swing.JTable();
        jPanel4 = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        jTextFieldTara1 = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jComboBoxMarca1 = new javax.swing.JComboBox();
        eliminar = new javax.swing.JButton();
        modificar = new javax.swing.JButton();
        jLabel14 = new javax.swing.JLabel();
        jTextFieldPatente1 = new javax.swing.JTextField();
        jComboBoxModelo1 = new javax.swing.JComboBox();
        jPanel3 = new javax.swing.JPanel();
        ButtBuscar = new javax.swing.JPanel();
        jTextFieldAcopladoListar = new javax.swing.JTextField();
        jLabelDniCon = new javax.swing.JLabel();
        jLabelTelCon = new javax.swing.JLabel();
        jTextFielTaraAcopladoListar = new javax.swing.JTextField();
        jButtonBuscarCon = new javax.swing.JButton();
        jLabelApellidoCon = new javax.swing.JLabel();
        jComboBoxPatente = new javax.swing.JComboBox();
        jLabel7 = new javax.swing.JLabel();
        jTextFieldTaraListar = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jTextFieldMarcaListar = new javax.swing.JTextField();
        jTextFieldModeloListar = new javax.swing.JTextField();
        jButtonSalir = new javax.swing.JButton();
        jPanel7 = new javax.swing.JPanel();
        jTextFieldUsuario2 = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Gestionar Transporte - Sistema Gestor de Pesaje para Bodegas");

        jTabbedPane1.setForeground(new java.awt.Color(102, 0, 102));
        jTabbedPane1.setFont(new java.awt.Font("Segoe UI", 3, 12));

        jButtonGuardar.setFont(new java.awt.Font("Segoe UI", 3, 12));
        jButtonGuardar.setForeground(new java.awt.Color(102, 0, 102));
        jButtonGuardar.setText("Guardar");
        jButtonGuardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonGuardarActionPerformed(evt);
            }
        });

        jLabel4.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel4.setText("tara:");

        jTextFieldTara.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jLabel2.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel2.setText("Marca:");

        jLabel12.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel12.setText("Patente:");

        jTextFieldPatente.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jComboBoxMarca.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        jComboBoxMarca.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jComboBoxMarcaMouseClicked(evt);
            }
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jComboBoxMarcaMousePressed(evt);
            }
        });
        jComboBoxMarca.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxMarcaActionPerformed(evt);
            }
        });

        jLabel10.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel10.setText("Modelo:");

        jComboBoxModelo.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel12)
                            .addComponent(jLabel4)
                            .addComponent(jLabel2))
                        .addGap(41, 41, 41)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jComboBoxMarca, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(41, 41, 41)
                                .addComponent(jLabel10)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jComboBoxModelo, 0, 129, Short.MAX_VALUE))
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(jTextFieldTara, javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jTextFieldPatente, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 166, Short.MAX_VALUE)))
                        .addGap(150, 150, 150))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addComponent(jButtonGuardar)
                        .addGap(35, 35, 35))))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(11, 11, 11)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel12)
                    .addComponent(jTextFieldPatente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jTextFieldTara, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(55, 55, 55)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jComboBoxMarca, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10)
                    .addComponent(jLabel2)
                    .addComponent(jComboBoxModelo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(219, 219, 219)
                .addComponent(jButtonGuardar)
                .addGap(173, 173, 173))
        );

        jTabbedPane1.addTab("Alta Transporte", jPanel1);

        jScrollPane2.setAutoscrolls(true);

        jTableProductos.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        jTableProductos.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null}
            },
            new String [] {
                "Patente", "Marca", "Modelo", "Tara", "Acoplado", "Tara acoplado"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.Object.class, java.lang.Object.class, java.lang.Float.class, java.lang.Integer.class, java.lang.Float.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, true, true
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTableProductos.setAutoscrolls(false);
        jTableProductos.setFillsViewportHeight(true);
        jTableProductos.setMinimumSize(new java.awt.Dimension(55, 55));
        jTableProductos.setPreferredSize(new java.awt.Dimension(200, 42));
        jTableProductos.setRowHeight(14);
        jTableProductos.getTableHeader().setResizingAllowed(false);
        jTableProductos.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTableProductosMouseClicked(evt);
            }
        });
        jScrollPane3.setViewportView(jTableProductos);

        jScrollPane2.setViewportView(jScrollPane3);

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED), "Datos del Transporte:", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Segoe UI", 3, 12), new java.awt.Color(102, 0, 102))); // NOI18N

        jLabel5.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel5.setText("Tara:");

        jTextFieldTara1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        jTextFieldTara1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldTara1ActionPerformed(evt);
            }
        });

        jLabel3.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel3.setText("Marca:");

        jLabel11.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel11.setText("Modelo:");

        jComboBoxMarca1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "ninguno" }));
        jComboBoxMarca1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        eliminar.setFont(new java.awt.Font("Segoe UI", 3, 12));
        eliminar.setForeground(new java.awt.Color(102, 0, 102));
        eliminar.setText("Eliminar");
        eliminar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                eliminarActionPerformed(evt);
            }
        });

        modificar.setFont(new java.awt.Font("Segoe UI", 3, 12));
        modificar.setForeground(new java.awt.Color(102, 0, 102));
        modificar.setText("Modificar");
        modificar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                modificarActionPerformed(evt);
            }
        });

        jLabel14.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel14.setText("Patente:");

        jTextFieldPatente1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jComboBoxModelo1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "ninguno" }));
        jComboBoxModelo1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel14)
                                    .addComponent(jLabel5))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jTextFieldTara1)
                                    .addComponent(jTextFieldPatente1, javax.swing.GroupLayout.DEFAULT_SIZE, 130, Short.MAX_VALUE)))
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addComponent(jLabel3)
                                .addGap(18, 18, 18)
                                .addComponent(jComboBoxMarca1, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(37, 37, 37)
                                .addComponent(jLabel11)
                                .addGap(18, 18, 18)
                                .addComponent(jComboBoxModelo1, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGap(245, 245, 245)
                        .addComponent(modificar)
                        .addGap(50, 50, 50)
                        .addComponent(eliminar)))
                .addContainerGap(107, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel14)
                    .addComponent(jTextFieldPatente1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldTara1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5))
                .addGap(52, 52, 52)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jComboBoxMarca1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(42, 42, 42)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(modificar)
                    .addComponent(eliminar))
                .addContainerGap())
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGap(115, 115, 115)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jComboBoxModelo1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel11))
                .addContainerGap(76, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 477, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(155, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(183, 183, 183))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(30, 30, 30)
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(34, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Modificar/Eliminar", jPanel2);

        ButtBuscar.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED), "Datos del Transporte", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Segoe UI", 3, 12), new java.awt.Color(102, 0, 102))); // NOI18N

        jTextFieldAcopladoListar.setEditable(false);

        jLabelDniCon.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabelDniCon.setText("Acoplado:");

        jLabelTelCon.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabelTelCon.setText("Tara Acoplado:");

        jTextFielTaraAcopladoListar.setEditable(false);

        jButtonBuscarCon.setFont(new java.awt.Font("Segoe UI", 3, 12));
        jButtonBuscarCon.setForeground(new java.awt.Color(102, 0, 102));
        jButtonBuscarCon.setMnemonic('B');
        jButtonBuscarCon.setText("Buscar");
        jButtonBuscarCon.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonBuscarConActionPerformed(evt);
            }
        });

        jLabelApellidoCon.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabelApellidoCon.setText("Patente");

        jComboBoxPatente.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jComboBoxPatenteMousePressed(evt);
            }
        });
        jComboBoxPatente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxPatenteActionPerformed(evt);
            }
        });

        jLabel7.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel7.setText("Tara:");

        jTextFieldTaraListar.setEditable(false);

        jLabel1.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel1.setText("Marca:");

        jLabel18.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel18.setText("Modelo:");

        jTextFieldMarcaListar.setEditable(false);

        jTextFieldModeloListar.setEditable(false);

        javax.swing.GroupLayout ButtBuscarLayout = new javax.swing.GroupLayout(ButtBuscar);
        ButtBuscar.setLayout(ButtBuscarLayout);
        ButtBuscarLayout.setHorizontalGroup(
            ButtBuscarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ButtBuscarLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(ButtBuscarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(ButtBuscarLayout.createSequentialGroup()
                        .addGroup(ButtBuscarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabelApellidoCon)
                            .addComponent(jLabel1)
                            .addComponent(jLabelTelCon)
                            .addComponent(jLabel18)
                            .addComponent(jLabel7)
                            .addComponent(jLabelDniCon))
                        .addGap(30, 30, 30)
                        .addGroup(ButtBuscarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jTextFieldAcopladoListar, javax.swing.GroupLayout.DEFAULT_SIZE, 347, Short.MAX_VALUE)
                            .addGroup(ButtBuscarLayout.createSequentialGroup()
                                .addGap(3, 3, 3)
                                .addComponent(jTextFielTaraAcopladoListar, javax.swing.GroupLayout.DEFAULT_SIZE, 344, Short.MAX_VALUE))
                            .addComponent(jTextFieldTaraListar, javax.swing.GroupLayout.DEFAULT_SIZE, 347, Short.MAX_VALUE)
                            .addComponent(jTextFieldModeloListar, javax.swing.GroupLayout.DEFAULT_SIZE, 347, Short.MAX_VALUE)
                            .addComponent(jTextFieldMarcaListar, javax.swing.GroupLayout.DEFAULT_SIZE, 347, Short.MAX_VALUE)
                            .addComponent(jComboBoxPatente, 0, 347, Short.MAX_VALUE))
                        .addGap(122, 122, 122))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, ButtBuscarLayout.createSequentialGroup()
                        .addComponent(jButtonBuscarCon)
                        .addGap(84, 84, 84))))
        );
        ButtBuscarLayout.setVerticalGroup(
            ButtBuscarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ButtBuscarLayout.createSequentialGroup()
                .addGroup(ButtBuscarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelApellidoCon)
                    .addComponent(jComboBoxPatente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(ButtBuscarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jTextFieldMarcaListar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(ButtBuscarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldModeloListar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel18))
                .addGap(13, 13, 13)
                .addGroup(ButtBuscarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldTaraListar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(ButtBuscarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldAcopladoListar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelDniCon))
                .addGap(9, 9, 9)
                .addGroup(ButtBuscarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelTelCon)
                    .addComponent(jTextFielTaraAcopladoListar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(48, 48, 48)
                .addComponent(jButtonBuscarCon)
                .addContainerGap(59, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(ButtBuscar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(33, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(ButtBuscar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(56, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Listar Transporte", jPanel3);

        jButtonSalir.setFont(new java.awt.Font("Segoe UI", 3, 12));
        jButtonSalir.setForeground(new java.awt.Color(102, 0, 102));
        jButtonSalir.setText("Salir");
        jButtonSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSalirActionPerformed(evt);
            }
        });

        jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED), "Usuario Registrado", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Segoe UI", 3, 11), new java.awt.Color(102, 0, 102))); // NOI18N

        jTextFieldUsuario2.setEditable(false);
        jTextFieldUsuario2.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTextFieldUsuario2, javax.swing.GroupLayout.DEFAULT_SIZE, 157, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTextFieldUsuario2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(28, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 647, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(11, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(773, Short.MAX_VALUE)
                .addComponent(jButtonSalir)
                .addGap(31, 31, 31))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 432, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(22, 22, 22)
                        .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 31, Short.MAX_VALUE)
                .addComponent(jButtonSalir)
                .addGap(20, 20, 20))
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-879)/2, (screenSize.height-544)/2, 879, 544);
    }// </editor-fold>//GEN-END:initComponents

    private void refresh() {
        jTextFieldTara.setText("");
        jTextFieldPatente.setText("");
        //    jTextFieldTaraAcoplado.setText("");


    }

private void jTableProductosMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTableProductosMouseClicked
    cargarCampos();
}//GEN-LAST:event_jTableProductosMouseClicked

private void jButtonSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSalirActionPerformed
    this.dispose();
}//GEN-LAST:event_jButtonSalirActionPerformed

////////////////////////////ALTA PRODUCTO////////////////////////////
private void jButtonGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonGuardarActionPerformed

    boolean ver = false;
    taraacoplado = "0";
    patente = jTextFieldPatente.getText();
    tara = jTextFieldTara.getText();
    //   taraacoplado = jTextFieldTaraAcoplado.getText();
    float taraacopladocamion = 0;

    float taracamion = Float.parseFloat(tara);
//    if (!taraacoplado.equals("")) {
//        taraacopladocamion = Float.parseFloat(taraacoplado);
//    } else {
//        taraacopladocamion = 0;
//    }


    String marcas = jComboBoxMarca.getSelectedItem().toString();
    try {
        marca = controladormarca.buscarMarcaNombre(marcas);

    } catch (Exception e) {
        System.out.println("No encontró la marca " + e);
    }

    String modelos = jComboBoxModelo.getSelectedItem().toString();
    try {
        modelo = controladormodelo.buscarModeloNombre(modelos);

    } catch (Exception e) {
        System.out.println("No encontró la marca " + e);
    }
    try {
        estadoespera = controladorestadoespera.buscarEstadoesperaNombre("EnEsperaControlCalidad");
    } catch (Exception ex) {
        Logger.getLogger(ABMTransporte.class.getName()).log(Level.SEVERE, null, ex);
    }



//    if (jCheckBoxAcoplado.isSelected()) {
//        acoplado = 1;
//        jTextFieldTaraAcoplado.setVisible(true);
//        System.out.println("acoplado " + acoplado);
//    } else {
//        acoplado = 0;
//        taraacoplado = "0";
//        System.out.println("acoplado " + acoplado);
//    }

    if (verificar(tara) && (verificar(patente))) {

        System.out.println("dentro del if paso el verificar");

        Transporte transporte = new Transporte();
        //patente, estadoespera, acoplado, marca, modelo, taraacopladocamion, taracamion

        transporte.setPatenteTransporte(patente);
        transporte.setEstadoespera(estadoespera);
        transporte.setAcoplado(acoplado);
        transporte.setMarca(marca);
        transporte.setModelo(modelo);
        transporte.setTaraAcoplado(new Float(1));
        transporte.setTaraTransporte(Float.parseFloat(tara));
        System.out.println("transporte " + transporte.toString());

        try {
            controladortransporte.guardarTransporte(transporte);
            JOptionPane.showMessageDialog(this, "Alta de Transporte registrada", "Alta Transporte", JOptionPane.INFORMATION_MESSAGE);

        } catch (Exception e) {
            System.out.println(e);
        }


        refresh();
        cargarTabla();
        cargarComboPatente();
        BuscarPedidosPendientes bp = new BuscarPedidosPendientes(op);
        bp.setVisible(true);
        this.dispose();


}//GEN-LAST:event_jButtonGuardarActionPerformed
    }

    private void cargarComboMarca() {

        try {
            listamarca = controladormarca.buscarTodosMarca();
        } catch (Exception e) {
        }
        jComboBoxMarca.removeAllItems();
        for (int i = 0; i < listamarca.size(); i++) {
            Vector fila = new Vector();
            Marca marca = (Marca) listamarca.get(i);
            fila.add(marca.getNombre());
            jComboBoxMarca.addItem(fila.get(0));
        }

    }

    private void cargarComboModelo() {

        try {
            listamodelo = controladormodelo.buscarTodosModelo();
        } catch (Exception e) {
        }
        jComboBoxModelo.removeAllItems();
        for (int i = 0; i < listamodelo.size(); i++) {
            Vector fila = new Vector();
            Modelo modelo = (Modelo) listamodelo.get(i);
            fila.add(modelo.getNombre());
            jComboBoxModelo.addItem(fila.get(0));
        }
    }

    private void cargarComboMarca1() {

        try {
            listacla = controladormarca.buscarTodosMarca();
        } catch (Exception e) {
        }
        jComboBoxMarca1.removeAllItems();
        for (int i = 0; i < listacla.size(); i++) {
            Vector fila = new Vector();
            Marca marca = (Marca) listacla.get(i);
            fila.add(marca.getNombre());
            jComboBoxMarca1.addItem(fila.get(0));
        }

    }

    private void cargarComboModelo1() {

        try {
            listamodelo = controladormodelo.buscarTodosModelo();
        } catch (Exception e) {
        }
        jComboBoxModelo1.removeAllItems();
        for (int i = 0; i < listamodelo.size(); i++) {
            Vector fila = new Vector();
            Modelo modelo = (Modelo) listamodelo.get(i);
            fila.add(modelo.getNombre());
            jComboBoxModelo1.addItem(fila.get(0));
        }
    }

    private void actualizarCombo(List lista1) {
        jComboBoxPatente.removeAllItems();
        for (int i = 0; i < lista1.size(); i++) {
            Vector fila = new Vector();
            Proveedor proveedor = (Proveedor) lista1.get(i);
            fila.add(proveedor.getCuitProveedor());
            jComboBoxPatente.addItem(fila.get(0));
        }
    }

    public void actualizarDatos(Producto productoSel) {

        jTextFieldTara1.setText(productoSel.getDescripcionProducto());
        jTextFieldPatente1.setText(productoSel.getNombreProducto());
//        jTextFieldTaraAcoplado1.setText(String.valueOf(productoSel.getPrecio()));
//        jTextFieldnroInv1.setText(String.valueOf(proveedorSel.getNroInv()));
//        jTextFielddireccion1.setText(proveedorSel.getDireccion());
//        jTextFieldtelefono1.setText(String.valueOf(proveedorSel.getTelefono1()));
//        jTextFieldtelefono2.setText(String.valueOf(proveedorSel.getTelefono2()));


    }

private void modificarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_modificarActionPerformed

    boolean ver = false;
    int ind = jTableProductos.getSelectedRow();
    if (ind < 0) {
        JOptionPane.showMessageDialog(this, "Seleccione un transporte", "Modificar Transporte", JOptionPane.INFORMATION_MESSAGE);
    } else {

        patente = jTextFieldPatente1.getText();
        tara = jTextFieldTara1.getText();
        float taras = Float.parseFloat(tara);
        // taraacoplado = jTextFieldTaraAcoplado1.getText();
        float taraacoplados = Float.parseFloat(taraacoplado);
        //  if (jCheckBoxAcoplado.isSelected() == true) {
        //       acoplado = 1;
        //  } else {
        //      acoplado = 0;
        //}
        String marcas = jComboBoxMarca1.getSelectedItem().toString();
        try {
            marca = controladormarca.buscarMarcaNombre(marcas);
        } catch (Exception e) {
        }
        String modelos = jComboBoxModelo1.getSelectedItem().toString();
        try {
            modelo = controladormodelo.buscarModeloNombre(modelos);
        } catch (Exception e) {
        }
//        nomproveedor = jComboBoxproveedor1.getSelectedItem().toString();
//        try {
//            o = controladorprovee.buscarProveedorRazon(nomproveedor);
//        } catch (Exception e) {
//        }

        ////////////////////
/////////////////////
        Transporte transporte = new Transporte();
        if (verificarT(tara) && verificar(patente)) {
            transporte.setAcoplado(acoplado);
            transporte.setMarca(marca);
            transporte.setModelo(modelo);
            transporte.setPatenteTransporte(patente);
            // transporte.setTaraAcoplado(taraacoplados);
            transporte.setTaraTransporte(taras);
            try {

                controladortransporte.modificarTransporte(transporte);
                JOptionPane.showMessageDialog(this, "Transporte Modificadp", "Modificar transporte", JOptionPane.INFORMATION_MESSAGE);

            } catch (Exception ex) {
                ex.printStackTrace();
            }
            cargarTabla();
            BuscarPedidosPendientes bp = new BuscarPedidosPendientes(op);
            bp.setVisible(true);
            this.dispose();
        }
    }

}//GEN-LAST:event_modificarActionPerformed

private void jTextFieldTara1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldTara1ActionPerformed
}//GEN-LAST:event_jTextFieldTara1ActionPerformed
    private void cargarCampos() {
        int fila = jTableProductos.getSelectedRow();
        int nromarca;
        int nromodelo;
        Transporte transporte = new Transporte();
        transporte = (Transporte) lista.get(fila);
        jTextFieldPatente1.setText(transporte.getPatenteTransporte());
        jTextFieldTara1.setText(String.valueOf(transporte.getTaraTransporte()));
        //     jTextFieldTaraAcoplado1.setText(String.valueOf(transporte.getTaraAcoplado()));
/////
//        nromarc = transporte.getIdmarca().getIdmarca();
//        String nclas = String.valueOf(nromarc);
//        int nroMarca = Integer.parseInt(nclas) - 1;
//        jComboBoxMarca1.setSelectedIndex(nroMarca);

//        nromodel = transporte.getIdmodelo().getIdmodelo();
//        String nclase = String.valueOf(nromodel);
//        int nroModelo = Integer.parseInt(nclase) - 1;
//        jComboBoxMarca1.setSelectedIndex(nroModelo);
//        ///
//
//        nroestado = operario.getEstadooperario().getIdestadooperario();
//        String nro = String.valueOf(nroestado);
//        int nroEstado = Integer.parseInt(nro) - 1;//es menos 1 por el indice que empieza en cero
//        jComboBoxestadoPersona1.setSelectedIndex(nroEstado);

        nromarca = transporte.getMarca().getIdmarca();
        String nros = String.valueOf(nromarca);
        int numeroMarca = Integer.parseInt(nros) - 1;
        jComboBoxMarca1.setSelectedIndex(numeroMarca);

        nromodelo = transporte.getModelo().getIdmodelo();
        String nross = String.valueOf(nromodelo);
        int numeroModelo = Integer.parseInt(nross) - 1;//es menos 1 por el indice que empieza en cero
        jComboBoxModelo1.setSelectedIndex(numeroModelo);
    }

    private void cargarTabla() {
        String[] encabezados = new String[5];
        encabezados[0] = "Patente";
        encabezados[1] = "Marca";
        encabezados[2] = "Modelo";
        encabezados[3] = "Tara";
        encabezados[4] = "Acoplado";


        tableModel = new TablaPersonalizada(encabezados);
        jTableProductos.setModel(tableModel);

        try {
            lista = controladortransporte.buscarTodosTransporte();
            System.out.println("tamaño de listao" + lista.size());

            for (int i = 0; i < lista.size(); i++) {
                Vector fila = new Vector();
                Transporte transporte = (Transporte) lista.get(i);
                fila.add(transporte.getPatenteTransporte());
                fila.add(transporte.getMarca().getNombre());
                fila.add(transporte.getModelo().getNombre());
                fila.add(String.valueOf(transporte.getTaraTransporte()));
                fila.add(transporte.getAcoplado());
                //   fila.add(transporte.getTaraAcoplado());
                tableModel.addRow(fila);
            }
        } catch (Exception e) {
        }
    }

    private void limpiarCampos() {
        jTextFieldTara1.setText("");
        jTextFieldPatente1.setText("");
        //     jTextFieldTaraAcoplado1.setText("");

    }

///////////////////ELIMINAR OPERARIO////////////////////////////////////////
private void eliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_eliminarActionPerformed
    int ind = jTableProductos.getSelectedRow();
    if (ind < 0) {
        JOptionPane.showMessageDialog(this, "Seleccione el Transporte que desea Eliminar", "Consulta Transporte", JOptionPane.INFORMATION_MESSAGE);
    } else {
        Transporte u = (Transporte) lista.get(ind);
        int rta = JOptionPane.showConfirmDialog(this, "Esta seguro de que desea ELIMINAR el Transporte:\n Cuit = " + u.getPatenteTransporte() + " ?", "Consulta Transporte", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);
        if (rta == 0) {
            try {
                controladortransporte.eliminarTransporte(u);
            } catch (Exception ex) {
                //JOptionPane.showMessageDialog(this, "No se puede eliminar este Transporte se incluirá esta fecha como fecha de baja", "Eliminar Transporte", JOptionPane.INFORMATION_MESSAGE);
            }

            JOptionPane.showMessageDialog(this, "Se eliminó el transporte", "Consulta Transporte", JOptionPane.INFORMATION_MESSAGE);
            cargarTabla();

            limpiarCampos();
            BuscarPedidosPendientes bp = new BuscarPedidosPendientes(op);
            bp.setVisible(true);
            this.dispose();
        }
    }
}//GEN-LAST:event_eliminarActionPerformed

////////////////////LISTAR PRODUCTO///////////////////////////////////////
    private void cargarComboPatente() {
        try {
            lista = controladortransporte.buscarTodosTransporte();
            System.out.println("tamaño de la lista de transportes " + lista.size());
        } catch (Exception e) {
        }
        jComboBoxPatente.removeAllItems();
        for (int i = 0; i < lista.size(); i++) {
            Vector fila = new Vector();
            Transporte transporte = (Transporte) lista.get(i);
            fila.add(transporte.getPatenteTransporte());
            jComboBoxPatente.addItem(fila.get(0));
        }
    }

private void jButtonBuscarConActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonBuscarConActionPerformed
///////////////
    System.out.println("");
    Transporte mitransporte = null;
    Object estetransporte = jComboBoxPatente.getSelectedItem();
    String nombre = estetransporte.toString();
    System.out.println("nombre transporte " + nombre);
    try {
        mitransporte = controladortransporte.buscarTransportePatente(nombre);
        System.out.println("mi producto " + mitransporte);
    } catch (Exception e) {
        JOptionPane.showMessageDialog(this, "El transporte ingresado no se ha encontrado.\n ", "Transporte", JOptionPane.ERROR_MESSAGE);
    }
    if (mitransporte != null) {
        jTextFieldMarcaListar.setText(mitransporte.getMarca().getNombre());
        jTextFieldModeloListar.setText(mitransporte.getModelo().getNombre());
        jTextFieldTaraListar.setText(String.valueOf(mitransporte.getTaraTransporte()));
        jTextFieldAcopladoListar.setText(String.valueOf(mitransporte.getAcoplado()));
        //  jTextFielTaraAcopladoListar.setText(String.valueOf(mitransporte.getTaraAcoplado()));
    }
}//GEN-LAST:event_jButtonBuscarConActionPerformed

//////////////////////////////////////////////
private void jComboBoxMarcaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxMarcaActionPerformed

    Clasificacionproducto miclas = null;
    Object estacla = jComboBoxMarca.getSelectedItem();
    String nombrecla = estacla.toString();//nombre del pais
    try {
        miclas = controladorclas.buscarClasificacionproductoNombre(nombrecla);
    } catch (Exception e) {
    }

    // cargarComboProvincias(miclas.getIdclasificacionproducto());//donde las provincias que se carguen pertenezcan al pais seleccionado

}//GEN-LAST:event_jComboBoxMarcaActionPerformed

//este da error porque devuelve nulo ya que no hay ninguna provincia seleccionada da nul pointer exception    
private void jComboBoxMarcaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jComboBoxMarcaMouseClicked
}//GEN-LAST:event_jComboBoxMarcaMouseClicked

private void jComboBoxMarcaMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jComboBoxMarcaMousePressed
}//GEN-LAST:event_jComboBoxMarcaMousePressed

/////////////////LISTAR////////////////////
private void jComboBoxPatenteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxPatenteActionPerformed
}//GEN-LAST:event_jComboBoxPatenteActionPerformed

private void jComboBoxPatenteMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jComboBoxPatenteMousePressed
    limpiarCampos();
    cargarComboPatente();// TODO add your handling code here:
}//GEN-LAST:event_jComboBoxPatenteMousePressed
//////////////////LISTAR///////////////
//Ojo qeu no verifica bien el telefono. da error cuando se ingresa una letra.
    //razon, nroPrevSocial,  apellido, nombre, nroIB, nroInv, pais,  provincia,localidad, telefono1, telefono2, fechaAlta, fechaBaja

    private boolean verificarT(String tara) {
        boolean ver = false;
        if (tara.equals("")) {
            JOptionPane.showMessageDialog(this, "Complete todos los campos", "Error", JOptionPane.ERROR_MESSAGE);

        } else if (!validador.getInstance().soloContieneNumeros(tara)) {
            JOptionPane.showMessageDialog(this, "Tara invalido: Sólo ingrese números", "Error", JOptionPane.ERROR_MESSAGE);

        } else {
            ver = true;
        }
        return ver;
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel ButtBuscar;
    private javax.swing.JButton eliminar;
    private javax.swing.JButton jButtonBuscarCon;
    private javax.swing.JButton jButtonGuardar;
    private javax.swing.JButton jButtonSalir;
    private javax.swing.JComboBox jComboBoxMarca;
    private javax.swing.JComboBox jComboBoxMarca1;
    private javax.swing.JComboBox jComboBoxModelo;
    private javax.swing.JComboBox jComboBoxModelo1;
    private javax.swing.JComboBox jComboBoxPatente;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabelApellidoCon;
    private javax.swing.JLabel jLabelDniCon;
    private javax.swing.JLabel jLabelTelCon;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTable jTableProductos;
    private javax.swing.JTextField jTextFielTaraAcopladoListar;
    private javax.swing.JTextField jTextFieldAcopladoListar;
    private javax.swing.JTextField jTextFieldMarcaListar;
    private javax.swing.JTextField jTextFieldModeloListar;
    private javax.swing.JTextField jTextFieldPatente;
    private javax.swing.JTextField jTextFieldPatente1;
    private javax.swing.JTextField jTextFieldTara;
    private javax.swing.JTextField jTextFieldTara1;
    private javax.swing.JTextField jTextFieldTaraListar;
    private javax.swing.JTextField jTextFieldUsuario2;
    private javax.swing.JButton modificar;
    // End of variables declaration//GEN-END:variables

    private boolean verificar(String patente) {
        boolean ver = false;

        if (patente.equals("")) {
            JOptionPane.showMessageDialog(this, "Ingrese la patente del transportes", "Error", JOptionPane.ERROR_MESSAGE);
        } else if (!validador.getInstance().soloContieneLetrasYNumeros(patente)) {
            JOptionPane.showMessageDialog(this, "Patente: Ingrese solo letras y números", "Error", JOptionPane.ERROR_MESSAGE);
        } else if (!repetidaPatente(patente) == true) {
            JOptionPane.showMessageDialog(this, "Error la patente pertenece a otro transporte !!!", "Error", JOptionPane.ERROR_MESSAGE);
        } else {
            ver = true;
        }

        return ver;
    }

    private boolean repetidaPatente(String patente) {
        boolean estarepetido = false;
        Transporte transporte = new Transporte();
        try {
            transporte = controladortransporte.buscarTransportePatente(patente);
            estarepetido = false;
            System.out.println("Encontró la patente en un transporte");
        } catch (Exception e) {
            System.out.println("NO está repetida la patente en otro transporte");
            estarepetido = true;
        }
        return estarepetido;
    }
///////////////AGREGAR PROVEEDOR A PRODUCTO:
//    private void cargarComboNombreProdAgregar() {
//        try {
//            listap = controladorprod.buscarTodosProducto();
//            System.out.println("tamaño de la listap de Producto " + lista.size());
//        } catch (Exception e) {
//        }
//        jComboBoxNombreProdAgregar.removeAllItems();
//        for (int i = 0; i < listap.size(); i++) {
//            Vector fila = new Vector();
//            Producto prod = (Producto) listap.get(i);
//            fila.add(prod.getDescripcionProducto());
//            jComboBoxNombreProdAgregar.addItem(fila.get(0));
//        }
//    }
//    private void cargarComboRazonAgregar() {
//        try {
//            listaprov = controladorprovee.buscarTodosProveedor();
//            System.out.println("tamaño de la lista de proveedores " + listaprov.size());
//        } catch (Exception e) {
//        }
//        jComboBoxRazonAgregar.removeAllItems();
//        for (int i = 0; i < listaprov.size(); i++) {
//            Vector fila = new Vector();
//            Proveedor prove = (Proveedor) listaprov.get(i);
//            fila.add(prove.getRazonSocialProveedor());
//            jComboBoxRazonAgregar.addItem(fila.get(0));
//        }
//    }
//    private void mostrarEnLaTabla(Proveedorproducto pp) {
//        Proveedorproducto ppp = null;
//        System.out.println("creando la tabla");
//        String[] encabezados = new String[2];
//        encabezados[0] = "Nombre Producto";
//        encabezados[1] = "Razón Social";
//
//        tableModel = new TablaPersonalizada(encabezados);
//        jTableProvProdSel.setModel(tableModel);
//
//        Vector fila = new Vector();
//        // Proveedorproducto pro = (Proveedorproducto) listapp.get(i);
//        fila.add(pp.getProducto().getNombreProducto());
//        fila.add(pp.getProveedor().getRazonSocialProveedor());
//
//        tableModel.addRow(fila);
//        //  listapp.add(provprod);
//        try {
//            Long idpp=provprod.getIdproveedorproducto();
//            ppp=controladorprovprod.buscarProveedorproducto_X_idProveedorproducto(idpp);
//            
//        } catch (Exception e) {
//        }
//    }
//    private void mostrarDatosProducto(Producto productoSel) {
//
//            limpiarCamposProdAgregar();
//            jTextFieldDscAgregar.setText(productoSel.getDscproducto());
//            jTextFieldClasificacionAgregar.setText(productoSel.getIdclasificacion().getNombreclasificacion());
//            jTextFieldPrecioAgregar.setText(String.valueOf(productoSel.getPrecio()));
//
//        //}
//    }
//    private void limpiarCamposProdAgregar() {
//
//        jTextFieldDscAgregar.setText("");
//        jTextFieldClasificacionAgregar.setText("");
//        jTextFieldPrecioAgregar.setText("");
//
//
//
//    }
}
